package com.detrum.detrumdx.activity;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.detrum.ShareSettingActivity;
import com.detrum.base.BaseActivity;
import com.detrum.costomview.StateShow;
import com.detrum.costomview.StateShowCall;
import com.detrum.detrumdx.R;
import com.detrum.utils.LogUtils;
import com.detrum.utils.MyMethod;

import java.util.HashMap;

import static com.detrum.base.BaseFinal.dcam;

public class SelfSetting extends BaseActivity implements StateShowCall, View.OnClickListener, RadioGroup.OnCheckedChangeListener {
    private Context context;
    private TextView video_setting, person_setting_show, share_setting_show;
    private boolean videoShow, personShow;
    private StateShow state_batter, state_channel, state_video, state_capture,loop_video,osd;
    private LinearLayout video_setting_ll, dcam_second_ll;
    private TextView dcam_setting, qxd_setting, wb_setting, exposure_setting, ratio_setting,cutDown_setting,std_setting;
    private boolean dcamShow, qxdShow, wbShow, exposureShow, ratiosShow,cutDownShow,stdShow;
    private RadioGroup qxd_rg, wb_rg, exposure_rg, ratios_rg,cutDown_rg,std_rg;

    private HashMap<Integer, Integer> qxdMap = new HashMap<>();
    private HashMap<Integer, Integer> wbMap = new HashMap<>();
    private HashMap<Integer, Integer> exposureMap = new HashMap<>();
    private HashMap<Integer, Integer> ratiosMap = new HashMap<>();
    private HashMap<Integer, Integer> cutDownMap = new HashMap<>();
    private HashMap<Integer, Integer> stdMap = new HashMap<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_self_setting);
        context = SelfSetting.this;
        initView();
    }

    private void initView() {
        video_setting = findViewById(R.id.video_setting);
        person_setting_show = findViewById(R.id.person_setting_show);
        share_setting_show = findViewById(R.id.share_setting_show);
        state_batter = findViewById(R.id.state_batter);
        state_channel = findViewById(R.id.state_channel);
        state_video = findViewById(R.id.state_video);
        state_capture = findViewById(R.id.state_capture);
        loop_video = findViewById(R.id.loop_video);
        osd = findViewById(R.id.osd);
        video_setting_ll = findViewById(R.id.video_setting_ll);
        dcam_second_ll = findViewById(R.id.dcam_second_ll);
        cutDown_setting = findViewById(R.id.cutDown_setting);
        std_setting = findViewById(R.id.std_setting);

        state_batter.setStateShowCall(this);
        state_channel.setStateShowCall(this);
        state_video.setStateShowCall(this);
        state_capture.setStateShowCall(this);
        loop_video.setStateShowCall(this);
        osd.setStateShowCall(this);
        video_setting.setOnClickListener(this);
        person_setting_show.setOnClickListener(this);
        share_setting_show.setOnClickListener(this);
        cutDown_setting.setOnClickListener(this);
        std_setting.setOnClickListener(this);

        dcam_setting = findViewById(R.id.dcam_setting);
        dcam_setting.setOnClickListener(this);
        qxd_setting = findViewById(R.id.qxd_setting);
        wb_setting = findViewById(R.id.wb_setting);
        exposure_setting = findViewById(R.id.exposure_setting);
        ratio_setting = findViewById(R.id.ratio_setting);
        qxd_setting.setOnClickListener(this);
        wb_setting.setOnClickListener(this);
        exposure_setting.setOnClickListener(this);
        ratio_setting.setOnClickListener(this);

        qxd_rg = findViewById(R.id.qxd_rg);
        qxd_rg.setOnCheckedChangeListener(this);
        wb_rg = findViewById(R.id.wb_rg);
        wb_rg.setOnCheckedChangeListener(this);
        exposure_rg = findViewById(R.id.exposure_rg);
        exposure_rg.setOnCheckedChangeListener(this);
        ratios_rg = findViewById(R.id.ratios_rg);
        ratios_rg.setOnCheckedChangeListener(this);
        cutDown_rg = findViewById(R.id.cutDown_rg);
        cutDown_rg.setOnCheckedChangeListener(this);
        std_rg = findViewById(R.id.std_rg);
        std_rg.setOnCheckedChangeListener(this);

        qxdMap.put(0, R.id.qxd_exquisite);
        qxdMap.put(1, R.id.qxd_good);
        qxdMap.put(2, R.id.qxd_normal);

        wbMap.put(0, R.id.wb_auto);
        wbMap.put(1, R.id.wb_sun);
        wbMap.put(2, R.id.wb_cloudy);
        wbMap.put(3, R.id.wb_lamp);
        wbMap.put(4, R.id.wb_neon);

        exposureMap.put(0, R.id.exposure_0);
        exposureMap.put(1, R.id.exposure_1);
        exposureMap.put(2, R.id.exposure_2);
        exposureMap.put(3, R.id.exposure_3);
        exposureMap.put(4, R.id.exposure_4);
        exposureMap.put(5, R.id.exposure_5);
        exposureMap.put(6, R.id.exposure_6);
        exposureMap.put(7, R.id.exposure_7);
        exposureMap.put(8, R.id.exposure_8);
        exposureMap.put(9, R.id.exposure_9);
        exposureMap.put(10, R.id.exposure_10);
        exposureMap.put(11, R.id.exposure_11);
        exposureMap.put(12, R.id.exposure_12);
        exposureMap.put(13, R.id.exposure_13);

        ratiosMap.put(1, R.id.ratios_1);
        ratiosMap.put(2, R.id.ratios_2);
        ratiosMap.put(3, R.id.ratios_3);
        ratiosMap.put(4, R.id.ratios_4);
        ratiosMap.put(5, R.id.ratios_5);
        ratiosMap.put(6, R.id.ratios_6);

        cutDownMap.put(0,R.id.curDown_1);
        cutDownMap.put(1,R.id.curDown_2);
        cutDownMap.put(2,R.id.curDown_3);
        cutDownMap.put(2,R.id.curDown_4);

        stdMap.put(0,R.id.std_1);
        stdMap.put(1,R.id.std_2);
    }

    @Override
    protected void onResume() {
        super.onResume();
        boolean[] values = MyMethod.getSelectItem(context, new String[]{"battery", "channel", "video", "capture","recordPolicy","osd"});
        state_batter.setSwitch(values[0]);
        state_channel.setSwitch(values[1]);
        state_video.setSwitch(values[2]);
        state_capture.setSwitch(values[3]);
        loop_video.setSwitch(values[4]);
        osd.setSwitch(values[5]);
        setRG();
    }

    private void setRG() {
        int qxdNum = MyMethod.getNum(context, dcam, "qxd");
        int wbNum = MyMethod.getNum(context, dcam, "wb");
        int exposureNum = MyMethod.getNum(context, dcam, "exposure");
        int ratiosNum = MyMethod.getNum(context, dcam, "ratios");
        int cutDownNum = MyMethod.getNum(context,dcam,"cutDown");
        int stdNum = MyMethod.getNum(context,dcam,"tvMode");
        if (ratiosNum == 0) {
            ratiosNum = 1;
        }
        qxd_rg.check(qxdMap.get(qxdNum));
        wb_rg.check(wbMap.get(wbNum));
        exposure_rg.check(exposureMap.get(exposureNum));
        ratios_rg.check(ratiosMap.get(ratiosNum));
        int checkId = cutDownMap.get(cutDownNum);
        cutDown_rg.check(checkId);
        std_rg.check(stdMap.get(stdNum));
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    public void Select(View view, boolean isChecked) {
        switch (view.getId()) {
            case R.id.state_batter:
                MyMethod.saveSelectItem(context, new String[]{"battery"}, new boolean[]{isChecked});
                break;
            case R.id.state_channel:
                MyMethod.saveSelectItem(context, new String[]{"channel"}, new boolean[]{isChecked});
                break;
            case R.id.state_video:
                MyMethod.saveSelectItem(context, new String[]{"video"}, new boolean[]{isChecked});
                break;
            case R.id.state_capture:
                MyMethod.saveSelectItem(context, new String[]{"capture"}, new boolean[]{isChecked});
                break;
            case R.id.loop_video:
                MyMethod.saveSelectItem(context, new String[]{"recordPolicy"}, new boolean[]{isChecked});
                break;
            case R.id.osd:
                MyMethod.saveSelectItem(context,new String[]{"osd"},new boolean[]{isChecked});
                break;
        }
    }

    @Override
    public void onClick(View v) {
        if (v == video_setting) {
            if (videoShow) {
                videoHide();
            } else {
                videoShow();
                dcamHide();
            }
        } else if (v == person_setting_show) {
            if (personShow) {
                Drawable drawable = context.getResources().getDrawable(R.mipmap
                        .setting_allow_right);
                Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                        .self_set);
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
                person_setting_show.setCompoundDrawables(drawableLeft, null, drawable, null);
                personShow = false;
            } else {
                Drawable drawable = context.getResources().getDrawable(R.mipmap
                        .setting_allow_right);
                Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                        .self_set);
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
                person_setting_show.setCompoundDrawables(drawableLeft, null, drawable, null);
                personShow = true;
            }
        } else if (v == share_setting_show) {
            MyMethod.toActivity(SelfSetting.this, ShareSettingActivity.class);
        } else if (v == dcam_setting) {
            if (dcamShow) {
                dcamHide();
            } else {
                videoHide();
                dcamShow();
            }
        } else if (v == qxd_setting) {
            if (qxdShow) {
                qxdHide();
            } else {
                wbHide();
                exposureHide();
                ratiosHide();
                cutDownHide();
                stdHide();
                qxdShow();
            }
        } else if (v == wb_setting) {
            if (wbShow) {
                wbHide();
            } else {
                qxdHide();
                exposureHide();
                ratiosHide();
                cutDownHide();
                stdHide();
                wbShow();
            }
        } else if (v == exposure_setting) {
            if (exposureShow) {
                exposureHide();
            } else {
                qxdHide();
                wbHide();
                ratiosHide();
                cutDownHide();
                stdHide();
                exposureShow();
            }
        } else if (v == ratio_setting) {
            if (ratiosShow) {
                ratiosHide();
            } else {
                qxdHide();
                wbHide();
                exposureHide();
                cutDownHide();
                stdHide();
                ratiosShow();
            }
        }else if(v == cutDown_setting){
            if(cutDownShow){
                cutDownHide();
            }else{
                qxdHide();
                wbHide();
                exposureHide();
                ratiosHide();
                stdHide();
                cutDownShow();
            }
        }else if(v == std_setting){
            if(stdShow){
                stdHide();
            }else{
                qxdHide();
                wbHide();
                exposureHide();
                ratiosHide();
                cutDownHide();
                stdShow();
            }
        }
    }

    private void videoHide() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .mslogo3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        video_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        video_setting_ll.setBackgroundColor(getResources().getColor(R.color.white));
        video_setting_ll.setVisibility(View.GONE);
        videoShow = false;
    }

    private void videoShow() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .mslogo3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        video_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        video_setting_ll.setBackgroundColor(getResources().getColor(R.color.gray_b));
        video_setting_ll.setVisibility(View.VISIBLE);
        videoShow = true;
        dcam_second_ll.setVisibility(View.GONE);
    }

    private void dcamHide() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .sport2);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        dcam_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        dcam_second_ll.setBackgroundColor(getResources().getColor(R.color.white));
        dcam_second_ll.setVisibility(View.GONE);
        dcamShow = false;
    }

    private void dcamShow() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .sport2);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        dcam_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        dcam_second_ll.setBackgroundColor(getResources().getColor(R.color.gray_b));
        dcam_second_ll.setVisibility(View.VISIBLE);
        dcamShow = true;
    }

    private void qxdHide() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .qingxidu_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        qxd_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        qxd_rg.setBackgroundColor(getResources().getColor(R.color.gray_b));
        qxd_rg.setVisibility(View.GONE);
        qxdShow = false;
    }

    private void qxdShow() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .qingxidu_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        qxd_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        qxd_rg.setVisibility(View.VISIBLE);
        qxd_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        qxdShow = true;
    }

    private void wbHide() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .wb_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        wb_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        wb_rg.setVisibility(View.GONE);
        wb_rg.setBackgroundColor(getResources().getColor(R.color.gray_b));
        wbShow = false;
    }

    private void wbShow() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .wb_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        wb_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        wb_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        wb_rg.setVisibility(View.VISIBLE);
        wbShow = true;
    }

    private void exposureHide() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .exposure_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        exposure_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        exposure_rg.setVisibility(View.GONE);
        exposure_rg.setBackgroundColor(getResources().getColor(R.color.gray_b));
        exposureShow = false;
    }

    private void exposureShow() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .exposure_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        exposure_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        exposure_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        exposure_rg.setVisibility(View.VISIBLE);
        exposureShow = true;
    }

    private void ratiosHide() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .ratio_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        ratio_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        ratios_rg.setVisibility(View.GONE);
        ratios_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        ratiosShow = false;
    }

    private void ratiosShow() {
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .ratio_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        ratio_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        ratios_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        ratios_rg.setVisibility(View.VISIBLE);
        ratiosShow = true;
    }

    private void cutDownHide(){
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .djs_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        cutDown_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        cutDown_rg.setVisibility(View.GONE);
        cutDown_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        cutDownShow = false;
    }

    private void cutDownShow(){
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.mipmap
                .djs_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        cutDown_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        cutDown_rg.setVisibility(View.VISIBLE);
        cutDown_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        cutDownShow = true;
    }

    private void stdHide(){
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow_right);
        Drawable drawableLeft = context.getResources().getDrawable(R.drawable
                .video_std_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        std_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        std_rg.setVisibility(View.GONE);
        std_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        stdShow = false;
    }

    private void stdShow(){
        Drawable drawable = context.getResources().getDrawable(R.mipmap
                .setting_allow);
        Drawable drawableLeft = context.getResources().getDrawable(R.drawable
                .video_std_3);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        drawableLeft.setBounds(0, 0, drawableLeft.getMinimumWidth(), drawableLeft.getMinimumHeight());
        std_setting.setCompoundDrawables(drawableLeft, null, drawable, null);
        std_rg.setVisibility(View.VISIBLE);
        std_rg.setBackgroundColor(getResources().getColor(R.color.gray_9));
        stdShow = true;
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        if (group == qxd_rg) {
            if (checkedId == R.id.qxd_exquisite) {
                MyMethod.saveSingleValue(context, dcam, "qxd", 0);
            } else if (checkedId == R.id.qxd_good) {
                MyMethod.saveSingleValue(context, dcam, "qxd", 1);
            } else if (checkedId == R.id.qxd_normal) {
                MyMethod.saveSingleValue(context, dcam, "qxd", 2);
            }
        } else if (group == wb_rg) {
            if (checkedId == R.id.wb_auto) {
                MyMethod.saveSingleValue(context, dcam, "wb", 0);
            } else if (checkedId == R.id.wb_cloudy) {
                MyMethod.saveSingleValue(context, dcam, "wb", 2);
            } else if (checkedId == R.id.wb_sun) {
                MyMethod.saveSingleValue(context, dcam, "wb", 1);
            } else if (checkedId == R.id.wb_lamp) {
                MyMethod.saveSingleValue(context, dcam, "wb", 3);
            } else if (checkedId == R.id.wb_neon) {
                MyMethod.saveSingleValue(context, dcam, "wb", 4);
            }
        } else if (group == exposure_rg) {
            if (checkedId == R.id.exposure_1) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 1);
            } else if (checkedId == R.id.exposure_2) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 2);
            } else if (checkedId == R.id.exposure_3) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 3);
            } else if (checkedId == R.id.exposure_4) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 4);
            } else if (checkedId == R.id.exposure_5) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 5);
            } else if (checkedId == R.id.exposure_6) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 6);
            } else if (checkedId == R.id.exposure_7) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 7);
            } else if (checkedId == R.id.exposure_8) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 8);
            } else if (checkedId == R.id.exposure_9) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 9);
            } else if (checkedId == R.id.exposure_10) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 10);
            } else if (checkedId == R.id.exposure_11) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 11);
            } else if (checkedId == R.id.exposure_12) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 12);
            } else if (checkedId == R.id.exposure_13) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 13);
            } else if (checkedId == R.id.exposure_0) {
                MyMethod.saveSingleValue(context, dcam, "exposure", 0);
            }
        } else if (group == ratios_rg) {
            if (checkedId == R.id.ratios_1) {
                MyMethod.saveSingleValue(context, dcam, "ratios", 1);
            } else if (checkedId == R.id.ratios_2) {
                MyMethod.saveSingleValue(context, dcam, "ratios", 2);
            } else if (checkedId == R.id.ratios_3) {
                MyMethod.saveSingleValue(context, dcam, "ratios", 3);
            } else if (checkedId == R.id.ratios_4) {
                MyMethod.saveSingleValue(context, dcam, "ratios", 4);
            } else if (checkedId == R.id.ratios_5) {
                MyMethod.saveSingleValue(context, dcam, "ratios", 5);
            } else if (checkedId == R.id.ratios_6) {
                MyMethod.saveSingleValue(context, dcam, "ratios", 6);
            }
        }else if(group == cutDown_rg){
            if(checkedId == R.id.curDown_1){
                MyMethod.saveSingleValue(context, dcam, "cutDown", 0);
            }else if(checkedId == R.id.curDown_2){
                MyMethod.saveSingleValue(context, dcam, "cutDown", 1);
            }else if(checkedId == R.id.curDown_3){
                MyMethod.saveSingleValue(context, dcam, "cutDown", 2);
            }else if(checkedId == R.id.curDown_4){
                MyMethod.saveSingleValue(context, dcam, "cutDown", 3);
            }
        }else if(group == std_rg){
            if(checkedId == R.id.std_1){
                MyMethod.saveSingleValue(context, dcam, "tvMode", 0);
            }else if(checkedId == R.id.std_2){
                MyMethod.saveSingleValue(context, dcam, "tvMode", 1);
            }
        }
    }
}
